import math
def print_hi(name):
    print(f'Hi, {name}')  # Press ⌘F8 to toggle the breakpoint.

def greet(name):
    """多行注释：此函数用于问候用户"""  # 三引号注释
    print(f"Hello, {name}!")

if __name__ == '__main__':
    print_hi('Hello World')
    name = "Alice"  # 字符串（str）
    age = 25  # 整数（int）
    price = 19.99  # 浮点数（float）
    is_student = True  # 布尔值（bool）

    print(is_student)

    fruits = ["apple", "banana", "cherry"]  # 列表（可修改）
    print(fruits[0])  # 输出：apple

    person = {"name": "Bob", "age": 30}  # 字典（键值对）
    print(person["name"]) #输出：Bob

    num = 10
    if num > 0:
        print("正数")  # 缩进表示代码块
    elif num == 0:
        print("零")
    else:
        print("负数")
    # 输出：正数

    # for循环遍历列表
    for fruit in fruits:
        print(fruit)  # 逐行输出apple, banana, cherry

    # while循环计算累加
    total = 0
    i = 1
    while i <= 10:
        total += i
        i += 1
    print(total)  # 输出：55

    greet("A")        # 输出：Hello, A!

    print(math.sqrt(16))

    with open("test.txt", "w") as f:
        f.write("Python入门")

    with open("test.txt", "r") as f:
        content = f.read()

    print(content) # 输出: Python入门

    # 获取用户输入并判断奇偶
    number = int(input("请输入一个整数："))  # input函数获取输入
    if number % 2 == 0:
        print(f"{number}是偶数")
    else:
        print(f"{number}是奇数")